package com.huawei.hms.api;

import android.app.Activity;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.text.TextUtils;
import com.huawei.hms.api.Api.ApiOptions;
import com.huawei.hms.api.HuaweiApiClient.ConnectionCallbacks;
import com.huawei.hms.api.HuaweiApiClient.OnConnectionFailedListener;
import com.huawei.hms.core.aidl.IMessageEntity;
import com.huawei.hms.core.aidl.RequestHeader;
import com.huawei.hms.core.aidl.d;
import com.huawei.hms.core.aidl.e;
import com.huawei.hms.support.api.ResolveResult;
import com.huawei.hms.support.api.client.BundleResult;
import com.huawei.hms.support.api.client.InnerApiClient;
import com.huawei.hms.support.api.client.ResultCallback;
import com.huawei.hms.support.api.client.Status;
import com.huawei.hms.support.api.client.SubAppInfo;
import com.huawei.hms.support.api.core.ConnectService;
import com.huawei.hms.support.api.entity.auth.PermissionInfo;
import com.huawei.hms.support.api.entity.auth.Scope;
import com.huawei.hms.support.api.entity.core.CheckConnectInfo;
import com.huawei.hms.support.api.entity.core.CommonCode.ErrorCode;
import com.huawei.hms.support.api.entity.core.ConnectInfo;
import com.huawei.hms.support.api.entity.core.ConnectResp;
import com.huawei.hms.support.api.entity.core.DisconnectInfo;
import com.huawei.hms.support.api.entity.core.DisconnectResp;
import com.huawei.hms.support.api.entity.core.JosGetNoticeResp;
import com.huawei.hms.support.log.HMSLog;
import com.huawei.hms.utils.PackageManagerHelper;
import com.huawei.hms.utils.Util;
import com.huawei.updatesdk.UpdateSdkAPI;
import com.huawei.updatesdk.service.appmgr.bean.ApkUpgradeInfo;
import com.huawei.updatesdk.service.otaupdate.CheckUpdateCallBack;
import com.huawei.updatesdk.service.otaupdate.UpdateKey;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

public class HuaweiApiClientImpl extends HuaweiApiClient implements ServiceConnection, InnerApiClient {
    public static final String DEFAULT_ACCOUNT = "<<default account>>";
    public static final int SIGN_IN_MODE_OPTIONAL = 2;
    public static final int SIGN_IN_MODE_REQUIRED = 1;
    private static final Object a = new Object();
    private static final Object b = new Object();
    private final Context c;
    private final String d;
    private String e;
    private String f;
    private volatile d g;
    private String h;
    private WeakReference<Activity> i;
    private WeakReference<Activity> j;
    private boolean k = false;
    private AtomicInteger l = new AtomicInteger(1);
    private List<Scope> m;
    private List<PermissionInfo> n;
    private Map<Api<?>, ApiOptions> o;
    private SubAppInfo p;
    private long q = 0;
    private int r = 0;
    private ConnectionCallbacks s;
    private OnConnectionFailedListener t;
    private Handler u = null;
    private Handler v = null;
    private CheckUpdatelistener w = null;
    private CheckUpdateCallBack x = new CheckUpdateCallBack(this) {
        final /* synthetic */ HuaweiApiClientImpl a;

        {
            this.a = r1;
        }

        public void onUpdateInfo(Intent intent) {
            if (intent != null && this.a.w != null) {
                try {
                    int intExtra = intent.getIntExtra(UpdateKey.STATUS, -99);
                    int intExtra2 = intent.getIntExtra(UpdateKey.FAIL_CODE, -99);
                    HMSLog.i("HuaweiApiClientImpl", "onUpdateInfo status: " + intExtra + ",failcause: " + intExtra2 + ",isExit: " + intent.getBooleanExtra(UpdateKey.MUST_UPDATE, false));
                    if (intExtra == 7) {
                        ApkUpgradeInfo apkUpgradeInfo = (ApkUpgradeInfo) intent.getSerializableExtra(UpdateKey.INFO);
                        if (apkUpgradeInfo != null) {
                            HMSLog.i("HuaweiApiClientImpl", "onUpdateInfo: " + apkUpgradeInfo.toString());
                        }
                        this.a.w.onResult(1);
                    } else if (intExtra == 3) {
                        this.a.w.onResult(0);
                    } else {
                        this.a.w.onResult(-1);
                    }
                    this.a.w = null;
                } catch (Exception e) {
                    HMSLog.e("HuaweiApiClientImpl", "intent has some error" + e.getMessage());
                    this.a.w.onResult(-1);
                }
            }
        }

        public void onMarketInstallInfo(Intent intent) {
            if (intent != null) {
                int intExtra = intent.getIntExtra(UpdateKey.MARKET_DLD_STATUS, -99);
                int intExtra2 = intent.getIntExtra(UpdateKey.MARKET_INSTALL_STATE, -99);
                HMSLog.i("HuaweiApiClientImpl", "onMarketInstallInfo installState: " + intExtra2 + ",installType: " + intent.getIntExtra(UpdateKey.MARKET_INSTALL_TYPE, -99) + ",downloadCode: " + intExtra);
            }
        }

        public void onMarketStoreError(int i) {
            HMSLog.e("HuaweiApiClientImpl", "onMarketStoreError responseCode: " + i);
        }

        public void onUpdateStoreError(int i) {
            HMSLog.e("HuaweiApiClientImpl", "onUpdateStoreError responseCode: " + i);
        }
    };

    class a implements ResultCallback<ResolveResult<ConnectResp>> {
        final /* synthetic */ HuaweiApiClientImpl a;

        private a(HuaweiApiClientImpl huaweiApiClientImpl) {
            this.a = huaweiApiClientImpl;
        }

        public /* synthetic */ void onResult(Object obj) {
            a((ResolveResult) obj);
        }

        public void a(final ResolveResult<ConnectResp> resolveResult) {
            new Handler(Looper.getMainLooper()).post(new Runnable(this) {
                final /* synthetic */ a b;

                public void run() {
                    this.b.a.b(resolveResult);
                }
            });
        }
    }

    class b implements ResultCallback<ResolveResult<DisconnectResp>> {
        final /* synthetic */ HuaweiApiClientImpl a;

        private b(HuaweiApiClientImpl huaweiApiClientImpl) {
            this.a = huaweiApiClientImpl;
        }

        public /* synthetic */ void onResult(Object obj) {
            a((ResolveResult) obj);
        }

        public void a(final ResolveResult<DisconnectResp> resolveResult) {
            new Handler(Looper.getMainLooper()).post(new Runnable(this) {
                final /* synthetic */ b b;

                public void run() {
                    this.b.a.a(resolveResult);
                }
            });
        }
    }

    class c implements ResultCallback<ResolveResult<JosGetNoticeResp>> {
        final /* synthetic */ HuaweiApiClientImpl a;

        private c(HuaweiApiClientImpl huaweiApiClientImpl) {
            this.a = huaweiApiClientImpl;
        }

        public /* synthetic */ void onResult(Object obj) {
            a((ResolveResult) obj);
        }

        public void a(ResolveResult<JosGetNoticeResp> resolveResult) {
            if (resolveResult != null && resolveResult.getStatus().isSuccess()) {
                JosGetNoticeResp josGetNoticeResp = (JosGetNoticeResp) resolveResult.getValue();
                Intent noticeIntent = josGetNoticeResp.getNoticeIntent();
                if (noticeIntent != null && josGetNoticeResp.getStatusCode() == 0) {
                    HMSLog.i("HuaweiApiClientImpl", "get notice has intent.");
                    Activity validActivity = Util.getValidActivity((Activity) this.a.i.get(), this.a.getTopActivity());
                    if (validActivity == null) {
                        HMSLog.e("HuaweiApiClientImpl", "showNotice no valid activity!");
                        return;
                    }
                    this.a.k = true;
                    validActivity.startActivity(noticeIntent);
                }
            }
        }
    }

    public HuaweiApiClientImpl(Context context) {
        this.c = context;
        this.d = Util.getAppId(context);
        this.e = this.d;
        this.f = Util.getCpId(context);
    }

    public Context getContext() {
        return this.c;
    }

    public String getPackageName() {
        return this.c.getPackageName();
    }

    public String getAppID() {
        return this.e;
    }

    public String getCpID() {
        return this.f;
    }

    public String getTransportName() {
        return IPCTransport.class.getName();
    }

    public final SubAppInfo getSubAppInfo() {
        return this.p;
    }

    public List<Scope> getScopes() {
        return this.m;
    }

    public void setScopes(List<Scope> list) {
        this.m = list;
    }

    public List<PermissionInfo> getPermissionInfos() {
        return this.n;
    }

    public void setPermissionInfos(List<PermissionInfo> list) {
        this.n = list;
    }

    public Map<Api<?>, ApiOptions> getApiMap() {
        return this.o;
    }

    public void setApiMap(Map<Api<?>, ApiOptions> map) {
        this.o = map;
    }

    public d getService() {
        return this.g;
    }

    public String getSessionId() {
        return this.h;
    }

    public void setHasShowNotice(boolean z) {
        this.k = z;
    }

    public void connect(Activity activity) {
        HMSLog.i("HuaweiApiClientImpl", "====== HMSSDK version: 30003300 ======");
        int i = this.l.get();
        HMSLog.i("HuaweiApiClientImpl", "Enter connect, Connection Status: " + i);
        if (i != 3 && i != 5 && i != 2 && i != 4) {
            if (activity != null) {
                this.i = new WeakReference(activity);
                this.j = new WeakReference(activity);
            }
            this.e = TextUtils.isEmpty(this.d) ? Util.getAppId(this.c) : this.d;
            i = c();
            HMSLog.i("HuaweiApiClientImpl", "connect minVersion:" + i);
            HuaweiApiAvailability.setServicesVersionCode(i);
            int isHuaweiMobileServicesAvailable = HuaweiMobileServicesUtil.isHuaweiMobileServicesAvailable(this.c, i);
            HMSLog.i("HuaweiApiClientImpl", "In connect, isHuaweiMobileServicesAvailable result: " + isHuaweiMobileServicesAvailable);
            this.r = new PackageManagerHelper(this.c).getPackageVersionCode("com.huawei.hwid");
            if (isHuaweiMobileServicesAvailable == 0) {
                a(5);
                if (this.g != null) {
                    a(2);
                    k();
                    h();
                } else if (f()) {
                    g();
                } else {
                    a(1);
                    HMSLog.e("HuaweiApiClientImpl", "In connect, bind core service fail");
                    b();
                }
            } else if (this.t != null) {
                PendingIntent pendingIntent = null;
                if (!(this.i == null || this.i.get() == null)) {
                    pendingIntent = HuaweiApiAvailability.getInstance().getResolveErrorPendingIntent((Activity) this.i.get(), isHuaweiMobileServicesAvailable);
                }
                this.t.onConnectionFailed(new ConnectionResult(isHuaweiMobileServicesAvailable, pendingIntent));
            }
        }
    }

    private void a() {
        HMSLog.i("HuaweiApiClientImpl", "Enter sendForceConnectApiServceRequest.");
        ConnectService.forceConnect(this, l()).setResultCallback(new a());
    }

    public void connectForeground() {
        HMSLog.i("HuaweiApiClientImpl", "====== HMSSDK version: 30003300 ======");
        int i = this.l.get();
        HMSLog.i("HuaweiApiClientImpl", "Enter forceConnect, Connection Status: " + i);
        if (i != 3 && i != 5 && i != 2 && i != 4) {
            this.e = TextUtils.isEmpty(this.d) ? Util.getAppId(this.c) : this.d;
            HMSLog.i("HuaweiApiClientImpl", "bindservice状态" + f());
            a();
        }
    }

    private void b() {
        if (this.t != null) {
            int i;
            if (Util.isBackground(this.c)) {
                i = 7;
            } else {
                i = 6;
            }
            PendingIntent pendingIntent = null;
            if (!(this.i == null || this.i.get() == null)) {
                pendingIntent = HuaweiApiAvailability.getInstance().getResolveErrorPendingIntent((Activity) this.i.get(), i);
            }
            this.t.onConnectionFailed(new ConnectionResult(i, pendingIntent));
        }
    }

    private int c() {
        int hmsVersion = Util.getHmsVersion(this.c);
        if (hmsVersion != 0 && hmsVersion >= 20503000) {
            return hmsVersion;
        }
        hmsVersion = d();
        if (!e()) {
            if (hmsVersion < 20600000) {
                hmsVersion = 20600000;
            }
            return hmsVersion;
        } else if (hmsVersion < 20503000) {
            return 20503000;
        } else {
            return hmsVersion;
        }
    }

    private int d() {
        Map apiMap = getApiMap();
        if (apiMap == null) {
            return 0;
        }
        int i = 0;
        for (Api apiName : apiMap.keySet()) {
            int intValue;
            CharSequence apiName2 = apiName.getApiName();
            if (!TextUtils.isEmpty(apiName2)) {
                Integer num = (Integer) HuaweiApiAvailability.getApiMap().get(apiName2);
                if (num != null) {
                    intValue = num.intValue();
                    if (intValue > i) {
                        i = intValue;
                    }
                }
            }
            intValue = i;
            i = intValue;
        }
        return i;
    }

    private boolean e() {
        if (this.o != null) {
            for (Api apiName : this.o.keySet()) {
                if (HuaweiApiAvailability.HMS_API_NAME_GAME.equals(apiName.getApiName())) {
                    return true;
                }
            }
        }
        return false;
    }

    private void a(int i) {
        this.l.set(i);
    }

    private boolean f() {
        Intent intent = new Intent(HuaweiApiAvailability.SERVICES_ACTION);
        intent.setPackage("com.huawei.hwid");
        return this.c.bindService(intent, this, 1);
    }

    private void g() {
        synchronized (a) {
            if (this.u != null) {
                this.u.removeMessages(2);
            } else {
                this.u = new Handler(Looper.getMainLooper(), new Callback(this) {
                    final /* synthetic */ HuaweiApiClientImpl a;

                    {
                        this.a = r1;
                    }

                    public boolean handleMessage(Message message) {
                        if (message == null || message.what != 2) {
                            return false;
                        }
                        HMSLog.e("HuaweiApiClientImpl", "In connect, bind core service time out");
                        if (this.a.l.get() != 5) {
                            return true;
                        }
                        this.a.a(1);
                        this.a.b();
                        return true;
                    }
                });
            }
            this.u.sendEmptyMessageDelayed(2, 5000);
        }
    }

    private void h() {
        synchronized (b) {
            if (this.v != null) {
                this.v.removeMessages(3);
            } else {
                this.v = new Handler(Looper.getMainLooper(), new Callback(this) {
                    final /* synthetic */ HuaweiApiClientImpl a;

                    {
                        this.a = r1;
                    }

                    public boolean handleMessage(Message message) {
                        if (message == null || message.what != 3) {
                            return false;
                        }
                        HMSLog.e("HuaweiApiClientImpl", "In connect, process time out");
                        if (this.a.l.get() != 2) {
                            return true;
                        }
                        this.a.a(1);
                        return true;
                    }
                });
            }
            HMSLog.d("HuaweiApiClientImpl", "sendEmptyMessageDelayed for onConnectionResult 3 seconds. the result is : " + this.v.sendEmptyMessageDelayed(3, 3000));
        }
    }

    private void b(int i) {
        if (i == 2) {
            synchronized (a) {
                if (this.u != null) {
                    this.u.removeMessages(i);
                    this.u = null;
                }
            }
        }
        if (i == 3) {
            synchronized (b) {
                if (this.v != null) {
                    this.v.removeMessages(i);
                    this.v = null;
                }
            }
        }
        synchronized (a) {
            if (this.u != null) {
                this.u.removeMessages(2);
                this.u = null;
            }
        }
    }

    public void disconnect() {
        int i = this.l.get();
        HMSLog.i("HuaweiApiClientImpl", "Enter disconnect, Connection Status: " + i);
        switch (i) {
            case 2:
                a(4);
                return;
            case 3:
                a(4);
                i();
                return;
            case 5:
                b(2);
                a(4);
                return;
            default:
                return;
        }
    }

    public boolean isConnected() {
        if (this.r == 0) {
            this.r = new PackageManagerHelper(this.c).getPackageVersionCode("com.huawei.hwid");
        }
        if (this.r >= 20504000) {
            return innerIsConnected();
        }
        long currentTimeMillis = System.currentTimeMillis() - this.q;
        if (currentTimeMillis > 0 && currentTimeMillis < 300000) {
            return innerIsConnected();
        }
        if (innerIsConnected()) {
            Status status = ((ResolveResult) ConnectService.checkconnect(this, new CheckConnectInfo()).awaitOnAnyThread(2000, TimeUnit.MILLISECONDS)).getStatus();
            if (status.isSuccess()) {
                this.q = System.currentTimeMillis();
                return true;
            }
            int statusCode = status.getStatusCode();
            HMSLog.e("HuaweiApiClientImpl", "isConnected is false, statuscode:" + statusCode);
            if (statusCode != ErrorCode.EXECUTE_TIMEOUT) {
                m();
                a(1);
                this.q = System.currentTimeMillis();
            }
        }
        return false;
    }

    public boolean isConnecting() {
        int i = this.l.get();
        return i == 2 || i == 5;
    }

    public boolean innerIsConnected() {
        return this.l.get() == 3 || this.l.get() == 4;
    }

    public boolean setSubAppInfo(SubAppInfo subAppInfo) {
        HMSLog.i("HuaweiApiClientImpl", "Enter setSubAppInfo");
        if (subAppInfo == null) {
            HMSLog.e("HuaweiApiClientImpl", "subAppInfo is null");
            return false;
        }
        Object subAppID = subAppInfo.getSubAppID();
        if (TextUtils.isEmpty(subAppID)) {
            HMSLog.e("HuaweiApiClientImpl", "subAppId is empty");
            return false;
        }
        if (subAppID.equals(TextUtils.isEmpty(this.d) ? Util.getAppId(this.c) : this.d)) {
            HMSLog.e("HuaweiApiClientImpl", "subAppId is host appid");
            return false;
        }
        this.p = new SubAppInfo(subAppInfo);
        return true;
    }

    public void checkUpdate(Activity activity, CheckUpdatelistener checkUpdatelistener) {
        HMSLog.i("HuaweiApiClientImpl", "Enter checkUpdate");
        if (checkUpdatelistener == null) {
            HMSLog.e("HuaweiApiClientImpl", "listener is null!");
        } else if (activity == null || activity.isFinishing()) {
            HMSLog.e("HuaweiApiClientImpl", "checkUpdate, activity is illegal: " + activity);
            checkUpdatelistener.onResult(-1);
        } else {
            this.w = checkUpdatelistener;
            UpdateSdkAPI.checkClientOTAUpdate(activity, this.x, true, 0, true);
        }
    }

    public void onResume(Activity activity) {
        if (activity != null) {
            HMSLog.i("HuaweiApiClientImpl", "onResume");
            this.j = new WeakReference(activity);
        }
    }

    public void onPause(Activity activity) {
        HMSLog.i("HuaweiApiClientImpl", "onPause");
    }

    public Activity getTopActivity() {
        if (this.j == null) {
            return null;
        }
        return (Activity) this.j.get();
    }

    public void setConnectionCallbacks(ConnectionCallbacks connectionCallbacks) {
        this.s = connectionCallbacks;
    }

    public void setConnectionFailedListener(OnConnectionFailedListener onConnectionFailedListener) {
        this.t = onConnectionFailedListener;
    }

    private void i() {
        ConnectService.disconnect(this, j()).setResultCallback(new b());
    }

    private DisconnectInfo j() {
        List arrayList = new ArrayList();
        if (this.o != null) {
            for (Api apiName : this.o.keySet()) {
                arrayList.add(apiName.getApiName());
            }
        }
        return new DisconnectInfo(this.m, arrayList);
    }

    private void a(ResolveResult<DisconnectResp> resolveResult) {
        HMSLog.i("HuaweiApiClientImpl", "Enter onDisconnectionResult, disconnect from server result: " + resolveResult.getStatus().getStatusCode());
        m();
        a(1);
    }

    public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
        HMSLog.i("HuaweiApiClientImpl", "Enter onServiceConnected.");
        b(2);
        this.g = com.huawei.hms.core.aidl.d.a.a(iBinder);
        if (this.g == null) {
            HMSLog.e("HuaweiApiClientImpl", "In onServiceConnected, mCoreService must not be null.");
            m();
            a(1);
            if (this.t != null) {
                PendingIntent pendingIntent = null;
                if (!(this.i == null || this.i.get() == null)) {
                    pendingIntent = HuaweiApiAvailability.getInstance().getResolveErrorPendingIntent((Activity) this.i.get(), 10);
                }
                this.t.onConnectionFailed(new ConnectionResult(10, pendingIntent));
            }
        } else if (this.l.get() == 5) {
            a(2);
            k();
            h();
        } else if (this.l.get() != 3) {
            m();
        }
    }

    private void k() {
        HMSLog.i("HuaweiApiClientImpl", "Enter sendConnectApiServceRequest.");
        ConnectService.connect(this, l()).setResultCallback(new a());
    }

    private ConnectInfo l() {
        String packageSignature = new PackageManagerHelper(this.c).getPackageSignature(this.c.getPackageName());
        if (packageSignature == null) {
            packageSignature = "";
        }
        return new ConnectInfo(getApiNameList(), this.m, packageSignature, this.p == null ? null : this.p.getSubAppID());
    }

    private void b(ResolveResult<ConnectResp> resolveResult) {
        Object obj;
        PendingIntent pendingIntent = null;
        HMSLog.i("HuaweiApiClientImpl", "Enter onConnectionResult");
        b(3);
        ConnectResp connectResp = (ConnectResp) resolveResult.getValue();
        if (connectResp != null) {
            this.h = connectResp.sessionId;
        }
        if (this.p == null) {
            obj = null;
        } else {
            obj = this.p.getSubAppID();
        }
        if (!TextUtils.isEmpty(obj)) {
            this.e = obj;
        }
        int statusCode = resolveResult.getStatus().getStatusCode();
        HMSLog.i("HuaweiApiClientImpl", "Enter onConnectionResult, connect to server result: " + statusCode);
        if (Status.SUCCESS.equals(resolveResult.getStatus())) {
            if (resolveResult.getValue() != null) {
                ProtocolNegotiate.getInstance().negotiate(((ConnectResp) resolveResult.getValue()).protocolVersion);
            }
            a(3);
            if (this.s != null) {
                this.s.onConnected();
            }
            if (this.i != null) {
                n();
            }
        } else if (resolveResult.getStatus() == null || resolveResult.getStatus().getStatusCode() != 1001) {
            m();
            a(1);
            if (this.t != null) {
                if (!(this.i == null || this.i.get() == null)) {
                    pendingIntent = HuaweiApiAvailability.getInstance().getResolveErrorPendingIntent((Activity) this.i.get(), statusCode);
                }
                this.t.onConnectionFailed(new ConnectionResult(statusCode, pendingIntent));
            }
        } else {
            m();
            a(1);
            if (this.s != null) {
                this.s.onConnectionSuspended(3);
            }
        }
    }

    private void m() {
        Util.unBindServiceCatchException(this.c, this);
    }

    private void n() {
        if (this.k) {
            HMSLog.i("HuaweiApiClientImpl", "Connect notice has been shown.");
        } else if (HuaweiApiAvailability.getInstance().isHuaweiMobileNoticeAvailable(this.c) == 0) {
            ConnectService.getNotice(this, 0, HuaweiApiAvailability.HMS_SDK_VERSION_NAME).setResultCallback(new c());
        }
    }

    public void onServiceDisconnected(ComponentName componentName) {
        HMSLog.i("HuaweiApiClientImpl", "Enter onServiceDisconnected.");
        this.g = null;
        a(1);
        if (this.s != null) {
            this.s.onConnectionSuspended(1);
        }
    }

    public int asyncRequest(Bundle bundle, String str, int i, ResultCallback<BundleResult> resultCallback) {
        HMSLog.i("HuaweiApiClientImpl", "Enter asyncRequest.");
        if (resultCallback == null || str == null || bundle == null) {
            HMSLog.e("HuaweiApiClientImpl", "arguments is invalid.");
            return ErrorCode.ARGUMENTS_INVALID;
        } else if (innerIsConnected()) {
            com.huawei.hms.core.aidl.b bVar = new com.huawei.hms.core.aidl.b(str, i);
            e a = com.huawei.hms.core.aidl.a.a(bVar.c());
            bVar.a(bundle);
            IMessageEntity requestHeader = new RequestHeader(getAppID(), getPackageName(), 30003300, getSessionId());
            requestHeader.setApiNameList(getApiNameList());
            bVar.b = a.a(requestHeader, new Bundle());
            try {
                getService().a(bVar, new 4(this, resultCallback));
                return 0;
            } catch (RemoteException e) {
                HMSLog.e("HuaweiApiClientImpl", "remote exception:" + e.getMessage());
                return ErrorCode.INTERNAL_ERROR;
            }
        } else {
            HMSLog.e("HuaweiApiClientImpl", "client is unConnect.");
            return ErrorCode.CLIENT_API_INVALID;
        }
    }

    public List<String> getApiNameList() {
        List<String> arrayList = new ArrayList();
        if (this.o != null) {
            for (Api apiName : this.o.keySet()) {
                arrayList.add(apiName.getApiName());
            }
        }
        return arrayList;
    }
}
